#pragma once
// MESSAGE SET_PID2 PACKING

#define MAVLINK_MSG_ID_SET_PID2 192

MAVPACKED(
typedef struct __mavlink_set_pid2_t {
 int16_t pid4_p; /*<  PID4_P*/
 int16_t pid4_i; /*<  PID4_I*/
 int16_t pid4_d; /*<  PID4_D*/
 int16_t pid5_p; /*<  PID5_P*/
 int16_t pid5_i; /*<  PID5_I*/
 int16_t pid5_d; /*<  PID5_D*/
 int16_t pid6_p; /*<  PID6_P*/
 int16_t pid6_i; /*<  PID6_I*/
 int16_t pid6_d; /*<  PID6_D*/
}) mavlink_set_pid2_t;

#define MAVLINK_MSG_ID_SET_PID2_LEN 18
#define MAVLINK_MSG_ID_SET_PID2_MIN_LEN 18
#define MAVLINK_MSG_ID_192_LEN 18
#define MAVLINK_MSG_ID_192_MIN_LEN 18

#define MAVLINK_MSG_ID_SET_PID2_CRC 57
#define MAVLINK_MSG_ID_192_CRC 57



#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_SET_PID2 { \
    192, \
    "SET_PID2", \
    9, \
    {  { "pid4_p", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_set_pid2_t, pid4_p) }, \
         { "pid4_i", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_set_pid2_t, pid4_i) }, \
         { "pid4_d", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_set_pid2_t, pid4_d) }, \
         { "pid5_p", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_set_pid2_t, pid5_p) }, \
         { "pid5_i", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_set_pid2_t, pid5_i) }, \
         { "pid5_d", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_set_pid2_t, pid5_d) }, \
         { "pid6_p", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_set_pid2_t, pid6_p) }, \
         { "pid6_i", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_set_pid2_t, pid6_i) }, \
         { "pid6_d", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_set_pid2_t, pid6_d) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_SET_PID2 { \
    "SET_PID2", \
    9, \
    {  { "pid4_p", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_set_pid2_t, pid4_p) }, \
         { "pid4_i", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_set_pid2_t, pid4_i) }, \
         { "pid4_d", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_set_pid2_t, pid4_d) }, \
         { "pid5_p", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_set_pid2_t, pid5_p) }, \
         { "pid5_i", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_set_pid2_t, pid5_i) }, \
         { "pid5_d", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_set_pid2_t, pid5_d) }, \
         { "pid6_p", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_set_pid2_t, pid6_p) }, \
         { "pid6_i", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_set_pid2_t, pid6_i) }, \
         { "pid6_d", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_set_pid2_t, pid6_d) }, \
         } \
}
#endif

/**
 * @brief Pack a set_pid2 message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param pid4_p  PID4_P
 * @param pid4_i  PID4_I
 * @param pid4_d  PID4_D
 * @param pid5_p  PID5_P
 * @param pid5_i  PID5_I
 * @param pid5_d  PID5_D
 * @param pid6_p  PID6_P
 * @param pid6_i  PID6_I
 * @param pid6_d  PID6_D
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_set_pid2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               int16_t pid4_p, int16_t pid4_i, int16_t pid4_d, int16_t pid5_p, int16_t pid5_i, int16_t pid5_d, int16_t pid6_p, int16_t pid6_i, int16_t pid6_d)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_SET_PID2_LEN];
    _mav_put_int16_t(buf, 0, pid4_p);
    _mav_put_int16_t(buf, 2, pid4_i);
    _mav_put_int16_t(buf, 4, pid4_d);
    _mav_put_int16_t(buf, 6, pid5_p);
    _mav_put_int16_t(buf, 8, pid5_i);
    _mav_put_int16_t(buf, 10, pid5_d);
    _mav_put_int16_t(buf, 12, pid6_p);
    _mav_put_int16_t(buf, 14, pid6_i);
    _mav_put_int16_t(buf, 16, pid6_d);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_PID2_LEN);
#else
    mavlink_set_pid2_t packet;
    packet.pid4_p = pid4_p;
    packet.pid4_i = pid4_i;
    packet.pid4_d = pid4_d;
    packet.pid5_p = pid5_p;
    packet.pid5_i = pid5_i;
    packet.pid5_d = pid5_d;
    packet.pid6_p = pid6_p;
    packet.pid6_i = pid6_i;
    packet.pid6_d = pid6_d;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_PID2_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_SET_PID2;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_PID2_MIN_LEN, MAVLINK_MSG_ID_SET_PID2_LEN, MAVLINK_MSG_ID_SET_PID2_CRC);
}

/**
 * @brief Pack a set_pid2 message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param pid4_p  PID4_P
 * @param pid4_i  PID4_I
 * @param pid4_d  PID4_D
 * @param pid5_p  PID5_P
 * @param pid5_i  PID5_I
 * @param pid5_d  PID5_D
 * @param pid6_p  PID6_P
 * @param pid6_i  PID6_I
 * @param pid6_d  PID6_D
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_set_pid2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   int16_t pid4_p,int16_t pid4_i,int16_t pid4_d,int16_t pid5_p,int16_t pid5_i,int16_t pid5_d,int16_t pid6_p,int16_t pid6_i,int16_t pid6_d)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_SET_PID2_LEN];
    _mav_put_int16_t(buf, 0, pid4_p);
    _mav_put_int16_t(buf, 2, pid4_i);
    _mav_put_int16_t(buf, 4, pid4_d);
    _mav_put_int16_t(buf, 6, pid5_p);
    _mav_put_int16_t(buf, 8, pid5_i);
    _mav_put_int16_t(buf, 10, pid5_d);
    _mav_put_int16_t(buf, 12, pid6_p);
    _mav_put_int16_t(buf, 14, pid6_i);
    _mav_put_int16_t(buf, 16, pid6_d);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_PID2_LEN);
#else
    mavlink_set_pid2_t packet;
    packet.pid4_p = pid4_p;
    packet.pid4_i = pid4_i;
    packet.pid4_d = pid4_d;
    packet.pid5_p = pid5_p;
    packet.pid5_i = pid5_i;
    packet.pid5_d = pid5_d;
    packet.pid6_p = pid6_p;
    packet.pid6_i = pid6_i;
    packet.pid6_d = pid6_d;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_PID2_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_SET_PID2;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SET_PID2_MIN_LEN, MAVLINK_MSG_ID_SET_PID2_LEN, MAVLINK_MSG_ID_SET_PID2_CRC);
}

/**
 * @brief Encode a set_pid2 struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param set_pid2 C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_set_pid2_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_pid2_t* set_pid2)
{
    return mavlink_msg_set_pid2_pack(system_id, component_id, msg, set_pid2->pid4_p, set_pid2->pid4_i, set_pid2->pid4_d, set_pid2->pid5_p, set_pid2->pid5_i, set_pid2->pid5_d, set_pid2->pid6_p, set_pid2->pid6_i, set_pid2->pid6_d);
}

/**
 * @brief Encode a set_pid2 struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param set_pid2 C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_set_pid2_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_set_pid2_t* set_pid2)
{
    return mavlink_msg_set_pid2_pack_chan(system_id, component_id, chan, msg, set_pid2->pid4_p, set_pid2->pid4_i, set_pid2->pid4_d, set_pid2->pid5_p, set_pid2->pid5_i, set_pid2->pid5_d, set_pid2->pid6_p, set_pid2->pid6_i, set_pid2->pid6_d);
}

/**
 * @brief Send a set_pid2 message
 * @param chan MAVLink channel to send the message
 *
 * @param pid4_p  PID4_P
 * @param pid4_i  PID4_I
 * @param pid4_d  PID4_D
 * @param pid5_p  PID5_P
 * @param pid5_i  PID5_I
 * @param pid5_d  PID5_D
 * @param pid6_p  PID6_P
 * @param pid6_i  PID6_I
 * @param pid6_d  PID6_D
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_set_pid2_send(mavlink_channel_t chan, int16_t pid4_p, int16_t pid4_i, int16_t pid4_d, int16_t pid5_p, int16_t pid5_i, int16_t pid5_d, int16_t pid6_p, int16_t pid6_i, int16_t pid6_d)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_SET_PID2_LEN];
    _mav_put_int16_t(buf, 0, pid4_p);
    _mav_put_int16_t(buf, 2, pid4_i);
    _mav_put_int16_t(buf, 4, pid4_d);
    _mav_put_int16_t(buf, 6, pid5_p);
    _mav_put_int16_t(buf, 8, pid5_i);
    _mav_put_int16_t(buf, 10, pid5_d);
    _mav_put_int16_t(buf, 12, pid6_p);
    _mav_put_int16_t(buf, 14, pid6_i);
    _mav_put_int16_t(buf, 16, pid6_d);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_PID2, buf, MAVLINK_MSG_ID_SET_PID2_MIN_LEN, MAVLINK_MSG_ID_SET_PID2_LEN, MAVLINK_MSG_ID_SET_PID2_CRC);
#else
    mavlink_set_pid2_t packet;
    packet.pid4_p = pid4_p;
    packet.pid4_i = pid4_i;
    packet.pid4_d = pid4_d;
    packet.pid5_p = pid5_p;
    packet.pid5_i = pid5_i;
    packet.pid5_d = pid5_d;
    packet.pid6_p = pid6_p;
    packet.pid6_i = pid6_i;
    packet.pid6_d = pid6_d;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_PID2, (const char *)&packet, MAVLINK_MSG_ID_SET_PID2_MIN_LEN, MAVLINK_MSG_ID_SET_PID2_LEN, MAVLINK_MSG_ID_SET_PID2_CRC);
#endif
}

/**
 * @brief Send a set_pid2 message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_set_pid2_send_struct(mavlink_channel_t chan, const mavlink_set_pid2_t* set_pid2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_set_pid2_send(chan, set_pid2->pid4_p, set_pid2->pid4_i, set_pid2->pid4_d, set_pid2->pid5_p, set_pid2->pid5_i, set_pid2->pid5_d, set_pid2->pid6_p, set_pid2->pid6_i, set_pid2->pid6_d);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_PID2, (const char *)set_pid2, MAVLINK_MSG_ID_SET_PID2_MIN_LEN, MAVLINK_MSG_ID_SET_PID2_LEN, MAVLINK_MSG_ID_SET_PID2_CRC);
#endif
}

#if MAVLINK_MSG_ID_SET_PID2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_set_pid2_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  int16_t pid4_p, int16_t pid4_i, int16_t pid4_d, int16_t pid5_p, int16_t pid5_i, int16_t pid5_d, int16_t pid6_p, int16_t pid6_i, int16_t pid6_d)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;
    _mav_put_int16_t(buf, 0, pid4_p);
    _mav_put_int16_t(buf, 2, pid4_i);
    _mav_put_int16_t(buf, 4, pid4_d);
    _mav_put_int16_t(buf, 6, pid5_p);
    _mav_put_int16_t(buf, 8, pid5_i);
    _mav_put_int16_t(buf, 10, pid5_d);
    _mav_put_int16_t(buf, 12, pid6_p);
    _mav_put_int16_t(buf, 14, pid6_i);
    _mav_put_int16_t(buf, 16, pid6_d);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_PID2, buf, MAVLINK_MSG_ID_SET_PID2_MIN_LEN, MAVLINK_MSG_ID_SET_PID2_LEN, MAVLINK_MSG_ID_SET_PID2_CRC);
#else
    mavlink_set_pid2_t *packet = (mavlink_set_pid2_t *)msgbuf;
    packet->pid4_p = pid4_p;
    packet->pid4_i = pid4_i;
    packet->pid4_d = pid4_d;
    packet->pid5_p = pid5_p;
    packet->pid5_i = pid5_i;
    packet->pid5_d = pid5_d;
    packet->pid6_p = pid6_p;
    packet->pid6_i = pid6_i;
    packet->pid6_d = pid6_d;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_PID2, (const char *)packet, MAVLINK_MSG_ID_SET_PID2_MIN_LEN, MAVLINK_MSG_ID_SET_PID2_LEN, MAVLINK_MSG_ID_SET_PID2_CRC);
#endif
}
#endif

#endif

// MESSAGE SET_PID2 UNPACKING


/**
 * @brief Get field pid4_p from set_pid2 message
 *
 * @return  PID4_P
 */
static inline int16_t mavlink_msg_set_pid2_get_pid4_p(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  0);
}

/**
 * @brief Get field pid4_i from set_pid2 message
 *
 * @return  PID4_I
 */
static inline int16_t mavlink_msg_set_pid2_get_pid4_i(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  2);
}

/**
 * @brief Get field pid4_d from set_pid2 message
 *
 * @return  PID4_D
 */
static inline int16_t mavlink_msg_set_pid2_get_pid4_d(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  4);
}

/**
 * @brief Get field pid5_p from set_pid2 message
 *
 * @return  PID5_P
 */
static inline int16_t mavlink_msg_set_pid2_get_pid5_p(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  6);
}

/**
 * @brief Get field pid5_i from set_pid2 message
 *
 * @return  PID5_I
 */
static inline int16_t mavlink_msg_set_pid2_get_pid5_i(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  8);
}

/**
 * @brief Get field pid5_d from set_pid2 message
 *
 * @return  PID5_D
 */
static inline int16_t mavlink_msg_set_pid2_get_pid5_d(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  10);
}

/**
 * @brief Get field pid6_p from set_pid2 message
 *
 * @return  PID6_P
 */
static inline int16_t mavlink_msg_set_pid2_get_pid6_p(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  12);
}

/**
 * @brief Get field pid6_i from set_pid2 message
 *
 * @return  PID6_I
 */
static inline int16_t mavlink_msg_set_pid2_get_pid6_i(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  14);
}

/**
 * @brief Get field pid6_d from set_pid2 message
 *
 * @return  PID6_D
 */
static inline int16_t mavlink_msg_set_pid2_get_pid6_d(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  16);
}

/**
 * @brief Decode a set_pid2 message into a struct
 *
 * @param msg The message to decode
 * @param set_pid2 C-struct to decode the message contents into
 */
static inline void mavlink_msg_set_pid2_decode(const mavlink_message_t* msg, mavlink_set_pid2_t* set_pid2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    set_pid2->pid4_p = mavlink_msg_set_pid2_get_pid4_p(msg);
    set_pid2->pid4_i = mavlink_msg_set_pid2_get_pid4_i(msg);
    set_pid2->pid4_d = mavlink_msg_set_pid2_get_pid4_d(msg);
    set_pid2->pid5_p = mavlink_msg_set_pid2_get_pid5_p(msg);
    set_pid2->pid5_i = mavlink_msg_set_pid2_get_pid5_i(msg);
    set_pid2->pid5_d = mavlink_msg_set_pid2_get_pid5_d(msg);
    set_pid2->pid6_p = mavlink_msg_set_pid2_get_pid6_p(msg);
    set_pid2->pid6_i = mavlink_msg_set_pid2_get_pid6_i(msg);
    set_pid2->pid6_d = mavlink_msg_set_pid2_get_pid6_d(msg);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_SET_PID2_LEN? msg->len : MAVLINK_MSG_ID_SET_PID2_LEN;
        memset(set_pid2, 0, MAVLINK_MSG_ID_SET_PID2_LEN);
    memcpy(set_pid2, _MAV_PAYLOAD(msg), len);
#endif
}
